﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Galaktika.BI.Silverlight.ClientApp.Services
{
    [System.ServiceModel.ServiceContractAttribute(Namespace = "http://www.galaktika.by/bi/3.0/", ConfigurationName = "DataServiceRef.DataServiceSoap")]
    public interface DataServiceSoap
    {

        [System.ServiceModel.OperationContractAttribute(AsyncPattern = true, Action = "http://www.galaktika.by/bi/3.0/InvokeCommand", ReplyAction = "*")]
        System.IAsyncResult BeginInvokeCommand(InvokeSchema invoker, System.AsyncCallback callback, object asyncState);

        InvokeResultSchema EndInvokeCommand(System.IAsyncResult result);
    }

    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
    public interface DataServiceSoapChannel : DataServiceSoap, System.ServiceModel.IClientChannel
    {
    }

    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
    public partial class InvokeCommandCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs
    {

        private object[] results;

        public InvokeCommandCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
            base(exception, cancelled, userState)
        {
            this.results = results;
        }

        public InvokeResultSchema Result
        {
            get
            {
                base.RaiseExceptionIfNecessary();
                return ((InvokeResultSchema)(this.results[0]));
            }
        }
    }

    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
    public partial class DataServiceSoapClient : System.ServiceModel.ClientBase<DataServiceSoap>, DataServiceSoap
    {

        private BeginOperationDelegate onBeginInvokeCommandDelegate;

        private EndOperationDelegate onEndInvokeCommandDelegate;

        private System.Threading.SendOrPostCallback onInvokeCommandCompletedDelegate;

        private BeginOperationDelegate onBeginOpenDelegate;

        private EndOperationDelegate onEndOpenDelegate;

        private System.Threading.SendOrPostCallback onOpenCompletedDelegate;

        private BeginOperationDelegate onBeginCloseDelegate;

        private EndOperationDelegate onEndCloseDelegate;

        private System.Threading.SendOrPostCallback onCloseCompletedDelegate;

        public DataServiceSoapClient()
        {
        }

        public DataServiceSoapClient(string endpointConfigurationName) :
            base(endpointConfigurationName)
        {
        }

        public DataServiceSoapClient(string endpointConfigurationName, string remoteAddress) :
            base(endpointConfigurationName, remoteAddress)
        {
        }

        public DataServiceSoapClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
            base(endpointConfigurationName, remoteAddress)
        {
        }

        public DataServiceSoapClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
            base(binding, remoteAddress)
        {
        }

        public event System.EventHandler<InvokeCommandCompletedEventArgs> InvokeCommandCompleted;

        public event System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs> OpenCompleted;

        public event System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs> CloseCompleted;

        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
        System.IAsyncResult DataServiceSoap.BeginInvokeCommand(InvokeSchema invoker, System.AsyncCallback callback, object asyncState)
        {
            return base.Channel.BeginInvokeCommand(invoker, callback, asyncState);
        }

        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
        InvokeResultSchema DataServiceSoap.EndInvokeCommand(System.IAsyncResult result)
        {
            return base.Channel.EndInvokeCommand(result);
        }

        private System.IAsyncResult OnBeginInvokeCommand(object[] inValues, System.AsyncCallback callback, object asyncState)
        {
            InvokeSchema invoker = ((InvokeSchema)(inValues[0]));
            return ((DataServiceSoap)(this)).BeginInvokeCommand(invoker, callback, asyncState);
        }

        private object[] OnEndInvokeCommand(System.IAsyncResult result)
        {
            InvokeResultSchema retVal = ((DataServiceSoap)(this)).EndInvokeCommand(result);
            return new object[] {
                    retVal};
        }

        private void OnInvokeCommandCompleted(object state)
        {
            if ((this.InvokeCommandCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                this.InvokeCommandCompleted(this, new InvokeCommandCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void InvokeCommandAsync(InvokeSchema invoker)
        {
            this.InvokeCommandAsync(invoker, null);
        }

        public void InvokeCommandAsync(InvokeSchema invoker, object userState)
        {
            if ((this.onBeginInvokeCommandDelegate == null))
            {
                this.onBeginInvokeCommandDelegate = new BeginOperationDelegate(this.OnBeginInvokeCommand);
            }
            if ((this.onEndInvokeCommandDelegate == null))
            {
                this.onEndInvokeCommandDelegate = new EndOperationDelegate(this.OnEndInvokeCommand);
            }
            if ((this.onInvokeCommandCompletedDelegate == null))
            {
                this.onInvokeCommandCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnInvokeCommandCompleted);
            }
            base.InvokeAsync(this.onBeginInvokeCommandDelegate, new object[] {
                        invoker}, this.onEndInvokeCommandDelegate, this.onInvokeCommandCompletedDelegate, userState);
        }

        private System.IAsyncResult OnBeginOpen(object[] inValues, System.AsyncCallback callback, object asyncState)
        {
            return ((System.ServiceModel.ICommunicationObject)(this)).BeginOpen(callback, asyncState);
        }

        private object[] OnEndOpen(System.IAsyncResult result)
        {
            ((System.ServiceModel.ICommunicationObject)(this)).EndOpen(result);
            return null;
        }

        private void OnOpenCompleted(object state)
        {
            if ((this.OpenCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                this.OpenCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(e.Error, e.Cancelled, e.UserState));
            }
        }

        public void OpenAsync()
        {
            this.OpenAsync(null);
        }

        public void OpenAsync(object userState)
        {
            if ((this.onBeginOpenDelegate == null))
            {
                this.onBeginOpenDelegate = new BeginOperationDelegate(this.OnBeginOpen);
            }
            if ((this.onEndOpenDelegate == null))
            {
                this.onEndOpenDelegate = new EndOperationDelegate(this.OnEndOpen);
            }
            if ((this.onOpenCompletedDelegate == null))
            {
                this.onOpenCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnOpenCompleted);
            }
            base.InvokeAsync(this.onBeginOpenDelegate, null, this.onEndOpenDelegate, this.onOpenCompletedDelegate, userState);
        }

        private System.IAsyncResult OnBeginClose(object[] inValues, System.AsyncCallback callback, object asyncState)
        {
            return ((System.ServiceModel.ICommunicationObject)(this)).BeginClose(callback, asyncState);
        }

        private object[] OnEndClose(System.IAsyncResult result)
        {
            ((System.ServiceModel.ICommunicationObject)(this)).EndClose(result);
            return null;
        }

        private void OnCloseCompleted(object state)
        {
            if ((this.CloseCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                this.CloseCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(e.Error, e.Cancelled, e.UserState));
            }
        }

        public void CloseAsync()
        {
            this.CloseAsync(null);
        }

        public void CloseAsync(object userState)
        {
            if ((this.onBeginCloseDelegate == null))
            {
                this.onBeginCloseDelegate = new BeginOperationDelegate(this.OnBeginClose);
            }
            if ((this.onEndCloseDelegate == null))
            {
                this.onEndCloseDelegate = new EndOperationDelegate(this.OnEndClose);
            }
            if ((this.onCloseCompletedDelegate == null))
            {
                this.onCloseCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnCloseCompleted);
            }
            base.InvokeAsync(this.onBeginCloseDelegate, null, this.onEndCloseDelegate, this.onCloseCompletedDelegate, userState);
        }

        protected override DataServiceSoap CreateChannel()
        {
            return new DataServiceSoapClientChannel(this);
        }

        private class DataServiceSoapClientChannel : ChannelBase<DataServiceSoap>, DataServiceSoap
        {

            public DataServiceSoapClientChannel(System.ServiceModel.ClientBase<DataServiceSoap> client) :
                base(client)
            {
            }

            public System.IAsyncResult BeginInvokeCommand(InvokeSchema invoker, System.AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = invoker;
                System.IAsyncResult _result = base.BeginInvoke("InvokeCommand", _args, callback, asyncState);
                return _result;
            }

            public InvokeResultSchema EndInvokeCommand(System.IAsyncResult result)
            {
                object[] _args = new object[0];
                InvokeResultSchema _result = ((InvokeResultSchema)(base.EndInvoke("InvokeCommand", _args, result)));
                return _result;
            }
        }
    }
}
